//package com.huabo.monitor.controller;
//
//
//import com.hbfk.util.JsonBean;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiParam;
//import org.springframework.web.bind.annotation.RequestHeader;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//@RestController
//@Api(value = "评价结果", tags = {"评价结果相关"})
//@RequestMapping(value = "/nbkz")
//public class NKResultController {
//
//
//    /**
//     * 评价结果
//     *
//     * @return
//     */
//    @RequestMapping(value = "/pjgl/t08_proj_task_result")
//    public JsonBean t08_proj_task_result(@ApiParam(name = "token", value = "登录用户token", required = true) @RequestHeader("token") String token,
//                                         @ApiParam(name = "pageNumber", value = "分页当前页数", required = false) @RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
//                                         @ApiParam(name = "pageSize", value = "每页记录数", required = false) @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
//                                         @ApiParam(name = "assNumnber", value = "评价编号", required = false) @RequestParam(value = "assNumnber", required = false) Integer assNumnber,
//                                         @ApiParam(name = "assName", value = "评价姓名", required = false) @RequestParam(value = "assName", required = false)String assName,
//                                         @ApiParam(name = "startDate", value = "评价期限-开始时间", required = false) @RequestParam(value = "startDate", required = false)String startDate,
//                                         @ApiParam(name = "endDate", value = "评价期限-结束时间", required = false) @RequestParam(value = "endDate", required = false)String endDate) {
//
//
//
//    }
//
//    /**
//     * 查看评价结果
//     *
//     * @return
//     */
//    @RequestMapping(value = "/pjgl/t08_proj_initiate_task_result")
//    public ModelAndView t08_proj_org_result(BigDecimal assId, Integer pageNumber, HttpServletRequest request) {
//        TblStaff user = (TblStaff) request.getSession().getAttribute("longUser");
//        String id = request.getParameter("assIds");
//        if (assId == null && id != null) {
//            assId = new BigDecimal(id);
//        }
//        pageBean = this.tblAssessMarkService.findMarkByOrgGroupZuPing(assId, user.getStaffid(), pageNumber,
//                pageBean.getPageSize());
//        TblAssess assess = this.tblAssessService.get(assId);
//        ModelAndView mv = new ModelAndView();
//        mv.setViewName("nbkz/pjgl/t08_proj_initiate_task_result");
//        mv.addObject("pageBean", pageBean);
//        mv.addObject("project", assess);
//        mv.addObject("assId", assId);
//        // 为页面查找区域显隐藏赋值
//        String choiceSearch = request.getParameter("choiceSearch");
//        if (choiceSearch == null || "".equals(choiceSearch)) {
//            choiceSearch = "hide";
//        }
//        mv.addObject("choiceSearch", choiceSearch);
//        return mv;
//    }
//
//
//    /**
//     * 计算分数---评价对象
//     *
//     * @param assId
//     * @return
//     */
//    @RequestMapping(value = "/pjgl/calculate", produces = "application/json; charset=utf-8")
//    public @ResponseBody String calculate(String assId) {
//        String[] array = assId.split("#");
//        TblAssess assess = this.tblAssessService.get(new BigDecimal(array[0]));
//        if (!assess.getAssstatus().equals(TblAssess.JISUAN)) {
//            /* 要素得分项-评价分 */
//            List<TblAssessMark> assessMarks = this.tblAssessMarkService
//                    .getAssessMarkByAssIdAndOrgId(new BigDecimal(array[0]), new BigDecimal(array[1]));
//            for (TblAssessMark tblAssessMark : assessMarks) {
//                Set<TblAssessStaff> assessStaffs = tblAssessMark.getTblAssessStaffs();
//                double sum = 0;
//                for (TblAssessStaff tblAssessStaff : assessStaffs) {
//                    Double assWeight = tblAssessStaff.getAssweight();
//                    Integer score = tblAssessStaff.getScore();
//                    sum += score * assWeight / 100;
//                }
//                // 四舍五入
//                BigDecimal bigDecimal = new BigDecimal(sum).setScale(1, BigDecimal.ROUND_HALF_UP);// 保留1位小数
//                tblAssessMark.setScore(bigDecimal.doubleValue());
//                // 修改计算状态
//                tblAssessMark.setState(TblAssessMark.SUM);
//                this.tblAssessMarkService.update(tblAssessMark);
//            }
//            List<TblAssessMark> list = this.tblAssessMarkService.checkJiSuan(new BigDecimal(array[0]));
//            if (list.size() == 0) {
//                assess.setAssstatus(TblAssess.JISUAN);
//                this.tblAssessService.update(assess);
//                // 计算最终得分
//                List<TblAssesscategory> assesscategories = this.tblAssesscategoryService
//                        .getTreeRoot(assess.getTblAssesstemple().getAsstemid());
//                List<AssesscategoryTree> lists = getYaoSuBanFenZhi(new BigDecimal(array[1]), assess, assesscategories);
//                double sum1 = 0d;
//                for (AssesscategoryTree assesscategoryTree : lists) {
//                    double fen = 0d;
//                    if (assesscategoryTree.getListTree().size() == 0) {
//                        fen += assesscategoryTree.getYaosuScore()
//                                * (assesscategoryTree.getCatweight().doubleValue() / 100);
//                    }
//                    for (AssesscategoryTree tree : assesscategoryTree.getListTree()) {
//                        if (tree.getListTree().size() == 0) {
//                            fen += tree.getYaosuScore() * (tree.getCatweight().doubleValue() / 100);
//                        }
//                        for (AssesscategoryTree tree2 : tree.getListTree()) {
//                            fen += tree2.getYaosuScore() * (tree2.getCatweight().doubleValue() / 100);
//                        }
//                    }
//
//                    // fen = diguiPF(assesscategoryTree,fen);
//
//                    /*
//                     * double pfen = 0d; if (assesscategoryTree.getListTree().size() == 0) { fen =
//                     * assesscategoryTree.getYaosuScore()
//                     * (assesscategoryTree.getCatweight().doubleValue() / 100); } for
//                     * (AssesscategoryTree tree : assesscategoryTree.getListTree()) { pfen =
//                     * tree.getYaosuScore() * (tree.getCatweight().doubleValue() / 100); fen +=
//                     * pfen; }
//                     */
//                    sum1 += fen;
//                }
//                System.out.println("总分为：" + sum1);
//                BigDecimal bd = new BigDecimal(sum1).setScale(2, BigDecimal.ROUND_HALF_UP);// 保留两位小数
//                sum1 = bd.doubleValue();
//                System.out.println("--四舍五入--" + sum1);
//                TblOrganization organization = this.tblOrganizaService.loadTblOrganization(array[1].toString());
//                List<TblAssessTarget> assessTargets = this.tblAssessTargetService.getTarget(assess.getAssid(),
//                        organization.getOrgid());
//                if (assessTargets.size() > 0) {
//                    TblAssessTarget assessTarget = assessTargets.get(0);
//                    assessTarget.setFinalScore(sum1);
//                    assessTarget.setOrganization(organization);
//                    List<TblAssesslevel> assesslevels = this.tblAssesslevelService
//                            .getRegion(new BigDecimal(sum1).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue());
//                    if (assesslevels.size() > 0) {
//                        assessTarget.setFinalLevel(assesslevels.get(assesslevels.size() - 1).getLevelname());
//                    }
//                    this.tblAssessTargetService.update(assessTarget);
//                    return JsonBean.success();
//                } else {
//                    return JsonBean.error("计算失败");
//                }
//            }
//            return JsonBean.success();
//        } else {
//            return JsonBean.error("已经计算");
//        }
//    }
//}
